package com.sajhasite.dao;

import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.sajhasite.domain.entity.BaseEntity;
import com.sajhasite.domain.entity.Post;
import com.sajhasite.domain.entity.User;
@Repository
public class PostDao extends AbstractDaoHibernate<BaseEntity, Long> implements IPostDao {

	@Override
	public List<Post> getLastNPosts(int n) {
		Query query = getSession().getNamedQuery("getLastNPosts");
		/*query.setParameter("firstNrecord", n);*/
		query.setMaxResults(n);
		List<Post> list = query.list();
		return list;
	}

	@Override
	public Post loadPostById(long postId) {
		return (Post)getSession().load(Post.class, postId);
		
	}
	
	

	
}
